<?php
include "fonctions.php";
db_connect();

echo "<h3>".$_POST['name']."</h3>";

echo '<table id="presents" class="tablesorter">
				<thead>
					<tr><th>Pseudo pr&eacute;sents</th><th>&Eacute;tat utilisateur</th><th class = \'bouton\'></th></tr>
				</thead>
			<tbody>';
$req = "SELECT i.pseudo, c.etatUser FROM inscriptions i, contributeurs c WHERE i.nomAtelier = '".$_POST['name']."' AND c.pseudo = i.pseudo ;";
$res = mysql_query($req) or die (mysql_error());
 
while($ligne = mysql_fetch_array($res))
	{
		echo "<tr><td>".$ligne[0]."</td><td>".$ligne[1]."</td><td><input type='button' value='supprimer'  onclick=\"supprimer_pseudo_atelier('".$ligne[0]."','".$_POST['name']."')\"></td></tr>";
	}
				echo '</tbody>
			</table>
			
			<table id="inscriptible" class="tablesorter">
				<thead>
					<tr><th>Pseudo inscriptibles</th><th>&Eacute;tat utilisateur</th><th class = \'bouton\'></th></tr>
				</thead>
				<tbody>';
	
	$req = "SELECT prix FROM ateliers WHERE nomAtelier = '".$_POST['name']."';";
	$res = mysql_query($req) or die (mysql_error());
	$prix = mysql_fetch_array($res);
	$prix =  $prix[0];
	
	if ($prix == "0")
	{
		$req = "SELECT pseudo, etatUser FROM contributeurs WHERE (etatUser LIKE  '%adh%' OR etatUser LIKE  '%admin%' OR etatUser LIKE  '%contributeur%') AND pseudo NOT IN  (
		SELECT pseudo FROM inscriptions WHERE nomAtelier = '".$_POST['name']."')
		;";
	}
	else
	{
		$req = "SELECT pseudo, etatUser FROM contributeurs WHERE (etatUser LIKE  '%adh%' OR etatUser LIKE  '%admin%') AND pseudo NOT IN  (
		SELECT pseudo FROM inscriptions WHERE nomAtelier = '".$_POST['name']."')
		;";
	}
	$res = mysql_query($req) or die (mysql_error());
while($ligne = mysql_fetch_array($res))
	{
		echo "<tr><td>".$ligne[0]."</td><td>".$ligne[1]."</td><td><input type='button' value='inscrire'  onclick=\"inscrire('".$ligne[0]."','".$_POST['name']."')\"></td></tr>";
	}
			echo '</tbody>
			</table>';
?>